package com.yoyosys.common.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.yt.mybatis.entity.YtBaseEntityColumn;
import com.github.yt.mybatis.entity.YtColumnType;

import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Table
public class BaseEntity<T extends BaseEntity<T>> implements Serializable {

    private static final long serialVersionUID = 6468926052770326422L;

    // 创建时间
    @Column(name = "create_time")
    @YtBaseEntityColumn(YtColumnType.CREATE_TIME)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    // 修改时间
    @Column(name = "last_update_time")
    @YtBaseEntityColumn(YtColumnType.MODIFY_TIME)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastUpdateTime;

    // 创建人ID
    @Column(name = "creator")
    @YtBaseEntityColumn(YtColumnType.FOUNDER_ID)
    private Integer creator;

    // 修改人ID
    @Column(name = "last_updator")
    @YtBaseEntityColumn(YtColumnType.MODIFIER_ID)
    private Integer lastUpdator;


    // 删除标示
    @Column(name = "status", nullable = false)
    @YtBaseEntityColumn(YtColumnType.DELETE_FLAG)
    private Integer status;

    public Date getCreateTime() {
        return createTime;
    }

    public T setCreateTime(Date createTime) {
        this.createTime = createTime;
        return (T)this;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public T setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
        return (T)this;
    }

    public Integer getCreator() {
        return creator;
    }

    public T setCreator(Integer creator) {
        this.creator = creator;
        return (T)this;
    }

    public Integer getLastUpdator() {
        return lastUpdator;
    }

    public T setLastUpdator(Integer lastUpdator) {
        this.lastUpdator = lastUpdator;
        return (T)this;
    }

    public Integer getStatus() {
        return status;
    }

    public T setStatus(Integer status) {
        this.status = status;
        return (T)this;
    }
}
